package com.cyh.pangu.offer;

import com.cyh.pangu.offer.common.TreeNode;

public class Offer28 {
    public boolean isSymmetric(TreeNode root) {
        if (root == null) {
            return true;
        }
        return recur(root.left, root.right);
    }

    public boolean recur(TreeNode node1, TreeNode node2) {
        if (node1 == null && node2 == null) {
            return true;
        }

        if (node1 == null || node2 == null || node1.val != node2.val) {
            return false;
        }
        return recur(node1.left, node2.right) && recur(node1.right, node2.left);
    }

    public static void main(String[] args) {
        TreeNode root = new TreeNode();
        Offer28 offer28 = new Offer28();
        offer28.isSymmetric(root);
    }
}
